$.fn.serializeObject = function () {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function () {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
}

$.fn.setFormValue = function (options) {
    var $this = $(this);
    $.each(options, function (key, value) {
        var obj = $this.find("*[name=" + key + "]");
        if (obj.attr("type") == "checkbox") {
            if ($.type(value) === "boolean") {
                obj.attr("checked", value);
            }
            if ($.type(value) === "object") {
                $.each(value, function (i, item) {
                    $this.find("*[name=" + key + "][value=" + i + "]").attr("checked", item);
                })
            }
        } else if (obj.attr("type") == "radio") {
            $this.find("*[name=" + key + "][value=" + value + "]").attr("checked", true);
        } else {
            obj.val(value);
        }
    })
}